// import { createProtocol } from 'vue-cli-plugin-electron-builder/lib';
import { createProtocol } from 'vue-cli-plugin-electron-builder/lib';
const isDevelopment = process.env.NODE_ENV !== 'production';

export const ACHEME = 'app';
export const LOAD_URL = `${ACHEME}://./`;

// const devServerUrl = process.env.WEBPACK_DEV_SERVER_URL;

const devServerUrl = `http://localhost:${process.env.VUE_APP_PORT}`;

export function getRenderContentUrl(url, base = 'index.html') {
  const suffixUrl = url ? `/#/${url.startsWith('/') ? url.slice(1) : url}` : '';
  if (isDevelopment) {
    return devServerUrl + suffixUrl;
  }
  createProtocol(ACHEME);
  return LOAD_URL + base + suffixUrl;
}
